<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "/include/head_common.html">
<title>机构<#if office.id??&&office.id!=''>修改<#else>添加</#if></title>
<meta name="decorator" content="default" />
	<script type="text/javascript">
        $(document).ready(function () {
            $("#name").focus();
            $("#inputForm").validate({
                submitHandler: function (form) {
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
        function goback(){
        	$.cookie('goback','goback',{path: '/',expires: 1});
        	history.go(-1);
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="list">机构列表</a></li>
    <li class="active"><a href="edit?id=${office.id!''}">机构<#if office.id??&&office.id!=''>修改<#else>添加</#if></a></li>
</ul>
<br/>
<form id="inputForm" action="edit" method="post" class="form-horizontal">
    <input type="hidden" name="id" value="${office.id!''}"/>
    <input type="hidden" name="sort" value="${office.sort!'10'}"/>
    <div class="control-group">
        <label class="control-label">上级机构:</label>
        <div class="controls">
        	<#if parent??>
				<@wolfking.treeView id="office" name="parentId" 
							value="${office.parentId!''}" 
							labelName="${parent.name!''}"
                            labelValue="${parent.name!''}"
                            title="机构" url="/office/treeData" 
                            extId="${office.id!''}" 
                            cssClass="" 
                            allowClear="true">
					<#include "/tool/treeTag.html">
				</@wolfking.treeView>
			<#else>
    			<input type="text" value="默认的最高父级" maxlength="50" readonly="readonly"/>
    			<input type="hidden" name="parentId" value="${area.parentId!''}" maxlength="50" readonly="readonly"/>
    		</#if>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">归属区域:</label>
        <div class="controls">
			<@wolfking.treeView id="area" name="areaId" 
						value="${area.id!''}" 
						labelName="${area.name!''}"
                        labelValue="${area.name!''}"
                        title="区域" 
                        url="/area/treeData" 
                        allowClear="true">
				<#include "/tool/treeTag.html">
			</@wolfking.treeView>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">机构名称:</label>
        <div class="controls">
            <input id="name" type="text" name="name" value="${office.name!''}" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">机构编码:</label>
        <div class="controls">
            <input type="text" name="code" value="${office.code!''}" maxlength="50"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">机构类型:</label>
        <div class="controls">
           <select name="type" style="width:220px">
           		<#list types as dict>
           			<option value="${dict.value}" <#if office.type??&&dict.value==office.type> selected </#if>>${dict.label!''}</option>
           		</#list>
           </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">机构级别:</label>
        <div class="controls">
           <select name="grade" style="width:220px">
           		<#list grades as dict>
           			<option value="${dict.value}" <#if office.grade??&&dict.value==office.grade> selected </#if>>${dict.label!''}</option>
           		</#list>
           </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">是否可用:</label>
        <div class="controls">
           <select name="useable" style="width:220px">
           		<option value="1" <#if office.useable??&&office.grade='1'> selected </#if>>可用</option>
           		<option value="2" <#if office.useable??&&office.grade='0'> selected </#if>>不可用</option>
           </select>
        </div>
    </div>
    
    <div class="control-group">
        <label class="control-label">联系地址:</label>
        <div class="controls">
            <input  type="text" name="address" value="${office.address!''}" maxlength="50"/>
            <span class="help-inline"></span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">邮政编码:</label>
        <div class="controls">
            <input  type="text" name="zipCode" value="${office.zipCode!''}" maxlength="50"/>
            <span class="help-inline"></span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">负责人:</label>
        <div class="controls">
            <input  type="text" name="master" value="${office.master!''}" maxlength="50"/>
            <span class="help-inline"></span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">电话:</label>
        <div class="controls">
            <input  type="text" name="phone" value="${office.phone!''}" maxlength="50"/>
            <span class="help-inline"></span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">传真:</label>
        <div class="controls">
            <input  type="text" name="fax" value="${office.fax!''}" maxlength="50"/>
            <span class="help-inline"></span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">邮箱:</label>
        <div class="controls">
            <input  type="text" name="email" value="${office.email!''}" maxlength="50"/>
            <span class="help-inline"></span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">备注:</label>
        <div class="controls">
        	<textarea name="remarks">${office.remarks!''}</textarea>
        </div>
    </div>
    <div class="form-actions">
        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;&nbsp;&nbsp;&nbsp;
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="goback()"/>
    </div>
</form>
</body>
</html>